#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "databasemagr.h"
#include "myapp.h"

#include "tcpserver.h"


#include <QDateTime>
#include <QHostAddress>
#include <QHostInfo>

#include <QMessageBox>
#include <QDebug>


MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    // 初始化网络
    InitNetwork();

    qDebug()<<QString("本机IP：") << myHelper::GetIP();
}

MainWindow::~MainWindow()
{
    delete ui;
}

// 初始化网络
void MainWindow::InitNetwork()
{
    tcpMsgServer = new TcpMsgServer(this);
    bool bOk = tcpMsgServer->StartListen(1818);
    bOk ? qDebug("消息服务器监听成功,端口: 1818") : qDebug("消息服务器监听失败");

    tcpFileServer = new TcpFileServer(this);
    bOk = tcpFileServer->StartListen(1616);
    bOk ? qDebug("文件服务器监听成功,端口: 1616") : qDebug("文件服务器监听失败");

    connect(tcpMsgServer, SIGNAL(signalDownloadFile(QJsonValue)), tcpFileServer, SLOT(SltClientDownloadFile(QJsonValue)));

}
